package com.baimawangzi.recovery.dao.impl;

import com.baimawangzi.recovery.bean.Cate;
import com.baimawangzi.recovery.dao.CateDao;
import com.baimawangzi.recovery.util.dbutil.BeanHandler;
import com.baimawangzi.recovery.util.dbutil.OnlyHandler;

import java.util.List;

public class CateDaoImpl extends BaseDaoImpl<Cate>implements CateDao {
    public CateDaoImpl() {
        clazz= Cate.class;
        init();
    }
    public List<Cate> map(String sql, Object[] obj) {
        List<Cate> cates = queryRunner.query(sql, new BeanHandler<Cate>(clazz), obj);
        return cates;
    }

    @Override
    public int getId(String name) {
        String sql = "select id from t_cate where catename=?";
        Object[] obj={name};
        return (int)queryRunner.query(sql,new OnlyHandler(),obj).get(0);
    }

    @Override
    public List<Cate> getAll() {
        String sql="select * from t_cate where ?=?";
        Object[] objects={1,1};
        return queryRunner.query(sql,new BeanHandler<Cate>(clazz),objects);
    }
}
